<style>
	#TableOfMedia {
		width:100%;
	}
	#TableOfMedia th {
		font-size:11px;
		text-align:left;
		border-bottom: 1px solid #003a63;
	}
	#TableOfMedia td {
		font-size:11px;
		text-align:left;
	}
	#TableOfMedia td.odd {
		background-color:#eaefee;
	}
	#TableOfMedia a {
		font-size:11px;
		text-align:left;
	}	
</style>

<?php 
if(!isset($_GET['id']) || trim($_GET['id']) == "") {
	header("Location: index.php?action=collections");
}


global $DB;
$query = "select name from media_collections where id = " . $_GET['id'];
$DB->query($query);
$row = $DB->fetch_row();
?>

<h5><?php print $row['name']; ?></h5>
<table width="100%" id="TableOfMedia" cellspacing="0" cellpadding="5">
<tr><th>Date/Time</th><th>Title</th><th>Speaker</th><th>&nbsp;</th></tr>
<tr><td colspan="4" class="odd" style="text-align:right;"><a href="index.php?action=mediaitem&collId=<?php print $_GET['id'];?>&new">[New Item]</a></td></tr>

<?php 
$query = "select id,title,url,speaker,date_format(posted_date, '%M %e, %Y, %l:%i%p') as date_formatted_cool from media where coll_id = " . $_GET['id'] . " order by posted_date desc";
$DB->query($query);
for($i=0;$row = $DB->fetch_row();$i++) {
	($i%2==1)?$idText = 'class="odd"':$idText = '';
	print '<tr>';
	print '<td ' . $idText . '>';
	if(trim($row['date_formatted_cool']) != '') {
		print $row['date_formatted_cool'];
	}
	print '</td>';
	print '<td ' . $idText . '>';
	if(trim($row['url']) != '' && trim($row['title']) != '') {
		print $row['title'] . '';
	}
	print '</td>';
	print '<td ' . $idText . '>';
	if(trim($row['speaker']) != '') {
		print '<span>' . $row['speaker'] . '</span>';
	}
	print '</td>';
	print '<td ' . $idText . ' style="text-align:right;">';
	print '<a href="index.php?action=mediaitem&id='.$row['id'].'&collId='. $_GET['id'].'">[edit]</a>&nbsp;&nbsp;&nbsp;';
	print '</td>';
	print '</tr>';
}
?>
</table>
